package com.globallogic.capacitaciones.hibernate.domain;

import java.util.List;
import java.util.Set;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "custom_user")
public class User extends PersistentObject {

	@Column(name = "custom_firstname")
	private String firstname;

	@Column(name = "custom_lastname")
	private String lastname;

	@Column(name = "custom_username")
	private String username;

	@Column(name = "custom_password")
	private String password;

	@Column(name = "custom_email")
	private String email;

	@Column(name = "custom_rankingt")
	private Integer ranking;

	@Column(name = "custom_admin")
	private Boolean admin;

	@OneToMany
	private Set<Item> boughtItems;

	@OneToMany(mappedBy = "soldby")
	private List<Item> soldeds;

	@Embedded
	@AttributeOverrides({
			@AttributeOverride(name = "city", column = @Column(name = "home_city")),
			@AttributeOverride(name = "zipcode", column = @Column(name = "home_zipcode")),
			@AttributeOverride(name = "street", column = @Column(name = "home_street")) })
	private Address home;
	@Embedded
	@AttributeOverrides({
		@AttributeOverride(name = "city", column = @Column(name = "billing_city")),
		@AttributeOverride(name = "zipcode", column = @Column(name = "billing_zipcode")),
		@AttributeOverride(name = "street", column = @Column(name = "billing_street")) })
	private Address billing;
	@Embedded
	@AttributeOverrides({
		@AttributeOverride(name = "city", column = @Column(name = "shipping_city")),
		@AttributeOverride(name = "zipcode", column = @Column(name = "shipping_zipcode")),
		@AttributeOverride(name = "street", column = @Column(name = "shipping_street")) })
	private Address shipping;

	@OneToOne
	private BillingDetails defaultBilling;

	@OneToMany
	private List<BillingDetails> billingDetails;

	public User() {
		super();
		// TODO Auto-generated constructor stub
	}

	public User(String firstname, String lastname, String username,
			String password, String email, Integer ranking, Boolean admin,
			Set<Item> boughtItems, List<Item> soldeds, Address home,
			Address billing, Address shipping, BillingDetails defaultBilling,
			List<BillingDetails> billingDetails) {
		super();
		this.firstname = firstname;
		this.lastname = lastname;
		this.username = username;
		this.password = password;
		this.email = email;
		this.ranking = ranking;
		this.admin = admin;
		this.boughtItems = boughtItems;
		this.soldeds = soldeds;
		this.home = home;
		this.billing = billing;
		this.shipping = shipping;
		this.defaultBilling = defaultBilling;
		this.billingDetails = billingDetails;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Integer getRanking() {
		return ranking;
	}

	public void setRanking(Integer ranking) {
		this.ranking = ranking;
	}

	public Boolean getAdmin() {
		return admin;
	}

	public void setAdmin(Boolean admin) {
		this.admin = admin;
	}

	public Set<Item> getBoughtItems() {
		return boughtItems;
	}

	public void setBoughtItems(Set<Item> boughtItems) {
		this.boughtItems = boughtItems;
	}

	public List<Item> getSoldeds() {
		return soldeds;
	}

	public void setSoldeds(List<Item> soldeds) {
		this.soldeds = soldeds;
	}

	public Address getHome() {
		return home;
	}

	public void setHome(Address home) {
		this.home = home;
	}

	public Address getBilling() {
		return billing;
	}

	public void setBilling(Address billing) {
		this.billing = billing;
	}

	public Address getShipping() {
		return shipping;
	}

	public void setShipping(Address shipping) {
		this.shipping = shipping;
	}

	public BillingDetails getDefaultBilling() {
		return defaultBilling;
	}

	public void setDefaultBilling(BillingDetails defaultBilling) {
		this.defaultBilling = defaultBilling;
	}

	public List<BillingDetails> getBillingDetails() {
		return billingDetails;
	}

	public void setBillingDetails(List<BillingDetails> billingDetails) {
		this.billingDetails = billingDetails;
	}

}
